package icu.qx.gbs.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import icu.qx.gbs.domain.GbsGoodUnit;
import icu.qx.gbs.mapper.GbsGoodUnitMapper;
import icu.qx.gbs.service.IGbsGoodUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 物品单位Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-06
 */
@Service
public class GbsGoodUnitServiceImpl implements IGbsGoodUnitService {
    @Autowired
    private GbsGoodUnitMapper gbsGoodUnitMapper;

    /**
     * 查询物品单位
     *
     * @param guId 物品单位主键
     * @return 物品单位
     */
    @Override
    public GbsGoodUnit selectGbsGoodUnitByGuId(Long guId) {
        return gbsGoodUnitMapper.selectGbsGoodUnitByGuId(guId);
    }

    /**
     * 查询物品单位列表
     *
     * @param gbsGoodUnit 物品单位
     * @return 物品单位
     */
    @Override
    public List<GbsGoodUnit> selectGbsGoodUnitList(GbsGoodUnit gbsGoodUnit) {
        return gbsGoodUnitMapper.selectGbsGoodUnitList(gbsGoodUnit);
    }

    /**
     * 新增物品单位
     *
     * @param gbsGoodUnit 物品单位
     * @return 结果
     */
    @Override
    public int insertGbsGoodUnit(GbsGoodUnit gbsGoodUnit) {
        gbsGoodUnit.setCreateTime(DateUtils.getNowDate());
        gbsGoodUnit.setCreateBy(SecurityUtils.getUsername());
        return gbsGoodUnitMapper.insertGbsGoodUnit(gbsGoodUnit);
    }

    /**
     * 修改物品单位
     *
     * @param gbsGoodUnit 物品单位
     * @return 结果
     */
    @Override
    public int updateGbsGoodUnit(GbsGoodUnit gbsGoodUnit) {
        gbsGoodUnit.setUpdateTime(DateUtils.getNowDate());
        gbsGoodUnit.setUpdateBy(SecurityUtils.getUsername());
        return gbsGoodUnitMapper.updateGbsGoodUnit(gbsGoodUnit);
    }

    /**
     * 批量删除物品单位
     *
     * @param guIds 需要删除的物品单位主键
     * @return 结果
     */
    @Override
    public int deleteGbsGoodUnitByGuIds(Long[] guIds) {
        return gbsGoodUnitMapper.deleteGbsGoodUnitByGuIds(guIds);
    }

    /**
     * 删除物品单位信息
     *
     * @param guId 物品单位主键
     * @return 结果
     */
    @Override
    public int deleteGbsGoodUnitByGuId(Long guId) {
        return gbsGoodUnitMapper.deleteGbsGoodUnitByGuId(guId);
    }
}
